package chapters15_bingfa.chapters15_3;

/**
 * Created by xinxuchu on 2020/1/29.
 */
public class AssenablePointDemo  {

    static class Tourist extends Thread{
        AssemblepPoint ap;

        public Tourist(AssemblepPoint ap) {
            this.ap = ap;
        }

        @Override
        public void run(){
            try {
                //模拟先各自运行
                Thread.sleep((int)(Math.random()*1000));
                //集合
                ap.await();
                System.out.println("arrived!!!");
                //...集合后执行其他操作
            }catch (InterruptedException e){
            }
        }
    }

    public static void main(String[] args) {
        int num = 10;
        Tourist[] threads = new Tourist[num];
        AssemblepPoint ap = new AssemblepPoint(num);
        for (int i = 0; i < num; i++) {
            threads[i] = new Tourist(ap);
            threads[i].start();
        }
    }


}
